{extend name="main/index" /}
{block name="main"}
<style type="text/css">
    .form-group .col-xs-10{
        width:200px; 
        height:40px; 
        line-height:40px; 
        border:1px solid #CCC; 
    }
    .form-group .default{
       width:200px; 
        height:32px; 
        line-height:32px; 
        color:#999;
    }
    .form-group .error{
        height:32px; 
        line-height:32px; 
        color:#F00; 
    }
    .form-group .success{
        height:32px; 
        line-height:32px; 
        color:#096; 
    }
</style>
<div class="main-content">

    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="{:url('admin/safe/fee')}">费用总览</a>
            </li>
            <li class="active">添加费用总览</li>
        </ul><!-- .breadcrumb -->

        <div class="nav-search" id="nav-search">
            <form class="form-search">
                <span class="input-icon">
                    <input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
                    <i class="icon-search nav-search-icon"></i>
                </span>
            </form>
        </div><!-- #nav-search -->
    </div>
    <div class="page-content">
        <h3 class="header smaller lighter blue">添加费用总览</h3>
        <div class="col-xs-12">
            <form class="form-horizontal" action="{:url('admin/safe/addfee')}" onSubmit="return checkForm()">
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 项目名称: </label>

                    <div class="col-sm-9">
                        <input type="text" name="project_name" class="col-xs-10 col-sm-5" id="project_name" onBlur="checkUserName()" oninput="checkUserName()"/>
                        <span class="default" id="nameErr"></span> 
                    </div>
                </div>
                <div class="space-4"></div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-2">环境保护费(元): </label>

                    <div class="col-sm-9">
                        <input type="text" name="environmental_expenditure" class="col-xs-10 col-sm-5" id="environmental" onBlur="checkenvironmental()" oninput="checkenvironmental()"/>
                        <span class="default" id="environmentalErr"></span> 
                    </div>
                </div>
                <div class="space-4"></div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-2">文明施工费(元): </label>

                    <div class="col-sm-9">
                        <input type="text" name="civilized_costs" class="col-xs-10 col-sm-5" id="civilized" onBlur="checkcivilized()" oninput="checkcivilized()"/>
                        <span class="default" id="civilizedErr"></span> 
                    </div>
                </div>

                <div class="space-4"></div>


                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-2">安全施工费(元): </label>

                    <div class="col-sm-9">
                        <input type="text" name="safety_costs" class="col-xs-10 col-sm-5" id="safety" onBlur="checksafety()" oninput="checksafety()"/>
                        <span class="default" id="safetyErr"></span>
                    </div>
                </div>
                <div class="space-4"></div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-2">临时设施费(元): </label>

                    <div class="col-sm-9">
                        <input type="text" name="temporary_facility_fee" class="col-xs-10 col-sm-5" id="temporary" onBlur="checktemporary()" oninput="checktemporary()"/>
                        <span class="default" id="temporaryErr"></span>
                    </div>
                </div>

                <div class="space-4"></div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-2">劳务费(元): </label>

                    <div class="col-sm-9">
                        <input type="text" name="servicefee" class="col-xs-10 col-sm-5" id="servicefee" onBlur="checkservicefee()" oninput="checkservicefee()"/>
                        <span class="default" id="servicefeeErr"></span>
                    </div>
                </div>


                <div class="space-4"></div>

                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-tags">状态</label>

                    <div class="col-sm-9">
                        <input name="status" type="radio" value="1" checked="checked">开启 |
                        <input name="status" value="0" type="radio">关闭
                    </div>
                </div>
                <!--<div class="clearfix form-actions">-->

                <div >
                    <div class="col-md-offset-3 col-md-9">
                        <button class="btn btn-info" type="submit">
                            <i class="icon-ok bigger-110"></i>
                            提交
                        </button>

                        &nbsp; &nbsp; &nbsp;
                        <button class="btn" type="reset">
                            <i class="icon-undo bigger-110"></i>
                            重置
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>

</div>
<script type="text/javascript"> 
    function checkForm(){ 
        var nametip = checkUserName(); 
        var requirement = checkenvironmental();  
        var content = checkcivilized(); 
        var logging = checktemporary(); 
        var servicefee = checkservicefee();
        var safety = checksafety(); 
        return nametip && requirement && content && logging && servicefee && safety;
    } 
    
    function checkUserName(){ 
        var username = document.getElementById('project_name'); 
        var errname = document.getElementById('nameErr');
        var pattern = /^[A-Za-z0-9\u4e00-\u9fa5]{2,20}$/;
        if(username.value.length == 0){ 
            errname.innerHTML="项目名称不能为空"
            errname.className="error"
            return false; 
        }if(!pattern.test(username.value)){ 
            errname.innerHTML="项目名称不合规范"
            errname.className="error"
            return false; 
        }else{ 
            errname.innerHTML="OK"
            errname.className="success"; 
            return true; 
        } 
    } 

    function checkenvironmental(){ 
        var username = document.getElementById('environmental'); 
        var errname = document.getElementById('environmentalErr'); 
        var pattern = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
        if(username.value.length == 0){ 
            errname.innerHTML="环境费用不能为空"
            errname.className="error"
            return false; 
        }if(!pattern.test(username.value)){ 
            errname.innerHTML="费用不符合规则"
            errname.className="error"
            return false; 
        }else{ 
            errname.innerHTML="OK"
            errname.className="success"; 
            return true; 
        } 
    }

    function checkcivilized(){ 
        var username = document.getElementById('civilized'); 
        var errname = document.getElementById('civilizedErr'); 
        var pattern = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
        if(username.value.length == 0){ 
            errname.innerHTML="文明施工费不能为空"
            errname.className="error"
            return false; 
        }if(!pattern.test(username.value)){ 
            errname.innerHTML="费用不符合规则"
            errname.className="error"
            return false; 
        }else{ 
            errname.innerHTML="OK"
            errname.className="success"; 
            return true; 
        } 
    }

    function checksafety(){ 
        var username = document.getElementById('safety'); 
        var errname = document.getElementById('safetyErr'); 
        var pattern = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
        if(username.value.length == 0){ 
            errname.innerHTML="安全施工费不能为空"
            errname.className="error"
            return false; 
        }if(!pattern.test(username.value)){ 
            errname.innerHTML="费用不符合规则"
            errname.className="error"
            return false; 
        }else{ 
            errname.innerHTML="OK"
            errname.className="success"; 
            return true; 
        } 
    }

    function checktemporary(){ 
        var username = document.getElementById('temporary'); 
        var errname = document.getElementById('temporaryErr'); 
        var pattern = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
        if(username.value.length == 0){ 
            errname.innerHTML="临时设施费不能为空"
            errname.className="error"
            return false; 
        }if(!pattern.test(username.value)){ 
            errname.innerHTML="费用不符合规则"
            errname.className="error"
            return false; 
        }else{ 
            errname.innerHTML="OK"
            errname.className="success"; 
            return true; 
        } 
    }

    function checkservicefee(){ 
        var username = document.getElementById('servicefee'); 
        var errname = document.getElementById('servicefeeErr'); 
        var pattern = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
        if(username.value.length == 0){ 
            errname.innerHTML="劳务费不能为空"
            errname.className="error"
            return false; 
        }if(!pattern.test(username.value)){ 
            errname.innerHTML="费用不符合规则"
            errname.className="error"
            return false; 
        }else{ 
            errname.innerHTML="OK"
            errname.className="success"; 
            return true; 
        } 
    }

</script>


{/block}